namespace Vanilla.UI

// LABEL
class Label (Gadget):
	// PROPERTIES
	_text as string = ""
	Text as string:
		get:
			return _text
		set:
			_text = value
			Pack()
			Parent.Pack() unless Parent == null
			Redraw()
	
	_font as Font
	Font as Font:
		get:
			return Theme.DefaultFontFor(self) if _font == null
			return _font
		set:
			_font = value
			Pack()
			Parent.Pack() unless Parent == null
			Redraw()
	
	public _colour as Colour
	_has_colour = false
	
	public Colour as Colour:
		get:
			if _has_colour:
				return _colour
			else:
				return Theme.DefaultForegroundColourFor(self)
		set:
			_has_colour = true
			_colour = value
	
	// CONSTRUCTORS
	def constructor (p as Box):
		super(p)
	
	def constructor (p as Box, t as string, f as Font):
		self(p)
		_text = t
		_font = f
		Pack()
	
	def constructor (p as Box, t as string):
		self(p, t, null)
	
	// DRAW CONTENTS
	override def DrawContents (b as Brush):
		sz = Font.Extents(Text)
		b.MoveTo(Rect.Width/2 - sz.Width/2, Rect.Height/2 - sz.Height/2)
		b.Font = Font
		b.Colour = Colour
		b.Write(Text)
		//b.Stroke()
	
	// CONTAINS MOUSE AT
	override def ContainsMouseAt (x as double, y as double) as bool:
		return false
	
	// ARRANGE
	override def Arrange ():
		MinSize = Font.Size(Text)
	
	// TOSTRING
	override def ToString():
		return "<" + GetType().ToString() + " text=\"" + Text + "\" font-face=\"" + Font.Face + "\"/>"


